package com.example.mapper;

import com.example.pojo.Order;
import com.example.pojo.ShoppingCar;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

/**
 * @Description:
 * @author: GaoPeng
 * @date: 2021/5/26 21:31
 */
public interface ShoppingCarMapper extends Mapper<ShoppingCar> {

    @Select("select * from shopping_car where user_id=#{user_id}")
    List<ShoppingCar> selectAllByUser_id(Integer user_id);

    @Select("select * from shopping_car where product_id=#{id}")
    ShoppingCar selectByProductId(Integer id);

    /**
     * 11
     * @param amount
     * @param productId
     * @return
     */
    @Update("update shopping_car set amount=#{amount} where product_id=#{productId}")
    Integer updateAmountByProductId(@Param("amount") Integer amount, @Param("productId")Integer productId);

    @Delete("delete from shopping_car where product_id=#{productId}")
    Integer deleteByProductId(Integer productId);
}
